package simonxianyu.learn.springmybatis.db.dbsvc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import simonxianyu.learn.springmybatis.db.mapper.SysUserMapper;
import simonxianyu.learn.springmybatis.db.po.SysUser;

/**
 *
 * Created by simon on 2017/2/20.
 */
@Service
@Transactional(readOnly = true)
public class SysUserDbSvc extends BaseDbSvc<SysUserMapper, SysUser, String> {

  @Transactional
  public void saveOrUpdate(SysUser m) {
    if (m.getLoginId() == null) {
      mapper.save(m);
    }
  }

  @Transactional
  public void updateLastLogin(String userId) {
    mapper.updateLastLogin(userId);
  }

}
